<%@ page import="com.wuchao.service.serviceimpl.ServiceImpl" %>
<%@ page import="com.wuchao.entity.Pojo" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 吴超
  Date: 2022/4/24
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
a{
    text-decoration: none;
}
hideA{
    display: none;
  }span{
    color:red;
   }.sp1{
    color: black;
       }
        li{
            display: inline-block;
        }
    </style>
    <script src="../js/jquery.js"></script>
</head>
<body>

<table border="3">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>sex</th>
        <th>age</th>
        <th>操作</th>
    </tr>
    <%
        int currentPage=1;
        int pageSize=3;
        ServiceImpl sl = new ServiceImpl();
        if(request.getParameter("currentPage")!=null){
            currentPage= Integer.parseInt(request.getParameter("currentPage"));
        }
        if(request.getParameter("pageSize")!=null){
            pageSize= Integer.parseInt(request.getParameter("pageSize"));
        }
        int totalCount=sl.isLoading("select count(1) from t143");
        int totalPage=totalCount%pageSize==0?totalCount/pageSize:totalCount/pageSize+1;
        List<Pojo> poJo = sl.findPoJo("select * from t143 limit ?,?", (currentPage - 1) * pageSize, pageSize);
        for(Pojo xjj : poJo){  %>
    <tr>
        <td><%=xjj.getId()%></td>
        <td><%=xjj.getName()%></td>
        <td><%=xjj.getSex()%></td>
        <td><%=xjj.getAge()%></td>
        <td>删除修改</td>
    </tr>
    <%
        }
    %>
</table>
<span >累计找到条数：<%=totalCount%></span><span >每页展示数：<%=pageSize%></span>
<span>当前多少页/总计多少页：<%=currentPage%>/<%=totalPage%></span>
<span class="sp1"><%
        for(int i=1;i<=totalPage;i++){%>
    <li <%=i==currentPage?"style=\"color:red;\"":""%>><%=i%></li>
       <%
        }%> </span>
<a href="page.jsp?currentPage=1">首页</a>
<%--<a href="page.jsp?currentPage=<%=currentPage-1>=1?currentPage-1:1%>"
<%=currentPage%> >上一页</a>--%>
<a href="page.jsp?currentPage=<%=currentPage-1%>"
        <%=currentPage-1<1?"style=\"display: none;\"":""%> >上一页</a>
<a href="page.jsp?currentPage=<%=currentPage+1%>"
        <%=currentPage+1>totalPage?"style=\"display: none;\"":""%> >下一页</a>
<%--<a href="page.jsp?currentPage=<%=currentPage+1>=totalPage?totalPage:currentPage+1%>">下一页</a>--%>
<a href="page.jsp?currentPage=<%=totalPage%>">尾页</a>
<%--<form method="get" action="${pageContext.request.contextPath}/PageController">
  当前页  <input type="text" id="t1" name="currentPage" placeholder="请输入当前页">
    每页展示数  <input type="text" id="t2" name="pageSize" placeholder="请输入每页展示">
        <input type="submit" value="点我搜索" > </a>
</form>--%>



<script>
$("tr:odd").css("background-color","yellow");
$("form").submit(function (){
    var t1=$("#t1").val();
    var t2=$("#t2").val();
    if(t1==""||t1==null){
        alert("不能为空")
        return false;
    }if(t2==""||t2==null){
        alert("不能为空")
        return false;
    }return true;
} );
</script>
</body>
</html>
